//
//  LKJsonRequestManager.h
//  Live
//
//  Created by Pie on 2017/7/26.
//  Copyright © 2017年 LaKa. All rights reserved.
//

#import <AFNetworking/AFNetworking.h>

NS_ASSUME_NONNULL_BEGIN
typedef void (^LKJsonQuerySuccessBlock)(id _Nullable responseObject);
typedef void (^LKJsonQueryFailureBlock)(NSError * _Nullable error);
typedef void (^LKUploadProgressBlock)(NSProgress * _Nonnull uploadProgress);

@interface LKJsonRequestManager : AFHTTPSessionManager

@property (strong, nonatomic, readonly) NSURLSessionDataTask * _Nullable currentDataTask;
@property (strong, nonatomic, readonly) NSURL * _Nullable wholeQureyUrl;

+ (instancetype)requestManager:(NSString*)serverUrl;

/**
 HTTP请求公共头
 
 @return 公共头信息词典
 */
+ (NSDictionary *_Nullable)commonHTTPHeaderField;

- (void)setCommonHTTPHeaderField;

@property (strong, nonatomic, readwrite) NSDictionary *commonHTTPHeaders; ///< 公共签名头
/**
 GET 请求，返回响应JSON数据
 
 @param urlStr 请求URL字符串
 @param parameters 请求参数
 @param success 响应成功回调
 @param failure 响应失败回调
 */
- (void)getJSONWithRelativeUrl:(NSString *_Nullable)urlStr
                    parameters:(NSDictionary *_Nullable)parameters
                       success:(LKJsonQuerySuccessBlock _Nullable )success
                       failure:(LKJsonQueryFailureBlock _Nullable )failure;

/**
 GET 请求，返回响应JSON数据
 
 @param urlStr 请求URL字符串
 @param parameters 请求参数
 @param success 响应成功回调
 @param failure 响应失败回调
 */
- (void)getJSONWithRelativeAllUrl:(NSString *)urlStr
                    parameters:(id)parameters
                       success:(LKJsonQuerySuccessBlock)success
                          failure:(LKJsonQueryFailureBlock)failure;

/**
 POST 请求，返回响应JSON数据
 
 @param urlStr 请求URL字符串
 @param parameters 请求参数
 @param success 响应成功回调
 @param failure 响应失败回调
 */
- (void)postJSONWithRelativeUrl:(NSString * _Nullable)urlStr
                     parameters:(NSDictionary * _Nullable)parameters
                        success:(LKJsonQuerySuccessBlock _Nullable)success
                        failure:(LKJsonQueryFailureBlock _Nullable)failure;


/**
 POST 请求，返回响应JSON数据
 
 @param urlStr 请求URL字符串
 @param parameters 请求参数
 @param imageData 图片
 @param type 1 是视频
 */
- (void)postJSONWithUploadPicturesUrl:(NSString * _Nullable)urlStr
                           parameters:(NSDictionary * _Nullable)parameters
                            imageData:(NSData * _Nullable)imageData
                                 type:(NSInteger)type
                              success:(LKJsonQuerySuccessBlock _Nullable)success
                              failure:(LKJsonQueryFailureBlock _Nullable)failure;


/// 接收所有参数类型的传值
/// @param urlStr 请求URL字符串
/// @param parameters 请求参数

- (void)postJSONWithRelativeAllUrl:(NSString *)urlStr
                     parameters:(id)parameters
                        success:(LKJsonQuerySuccessBlock)success
                           failure:(LKJsonQueryFailureBlock)failure;

/**
 PUT请求，返回响应JSON数据
 
 @param urlStr 请求URL字符串
 @param parameters 请求参数
 @param success 响应成功回调
 @param failure 响应失败回调
 */
- (void)putJSONWithRelativeUrl:(NSString *)urlStr
                     parameters:(NSDictionary *)parameters
                        success:(LKJsonQuerySuccessBlock)success
                       failure:(LKJsonQueryFailureBlock)failure;
/// 上传拖
/// @param urlStr  图片地址
/// @param parameters 内容
/// @param imageData 图片数据
/// @param type 类型

- (void)postJSONWithUploadPhotoUrl:(NSString * _Nullable)urlStr
                        parameters:(NSDictionary * _Nullable)parameters
                         imageData:(NSData * _Nullable)imageData
                              type:(NSInteger)type
                           success:(LKUploadProgressBlock _Nullable)cmUploadProgres
                           success:(LKJsonQuerySuccessBlock _Nullable)success
                           failure:(LKJsonQueryFailureBlock _Nullable)failure;

@end
NS_ASSUME_NONNULL_END
